#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include<QAction>
#include<QMenu>
#include<QMouseEvent>
#include<QtNetwork/QNetworkAccessManager>
#include<QtNetwork/QNetworkReply>
#include<QtDebug>
#include<weatherdata.h>
#include<QJsonArray>
#include<QJsonDocument>
#include<QJsonObject>
#include<QLabel>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();


protected:
 //鼠标事件
 void contextMenuEvent(QContextMenuEvent *event) override;
 void mousePressEvent(QMouseEvent * event )override;
 void mouseMoveEvent(QMouseEvent * event)override;

 void getWeatherInfo(QString cityCode);
 //解析JSON数据
 void parseJson(QByteArray &byteArray);
 //更新UI
 void updateUI();

 //重写父类的eventfilter方法
 bool eventFilter(QObject * watched,QEvent * event);

 //绘制高低温曲线
 void paintHighCurve();
 void paintLowCurve();

private slots:
 void on_pushButtont_sosuo_clicked();
 void onEnter();

private:
    Ui::MainWindow *ui;

    QMenu * mExitMenu; //右键退出的菜单
    QAction * mExitAct;//退出的行为-菜单项
    QPoint mOffset;//窗口移动时，鼠标与窗口左上角的偏移
    //Http请求
    QNetworkAccessManager *mNetworkAccessManager;
    void onReplied(QNetworkReply * reply); //槽函数
    Today mToday;
    weekday mday[6];

    //星期和日期
    QList<QLabel*> mWeekList;
    QList<QLabel*> mDateList;

    //天气和天气图标
    QList<QLabel*> mTypeList;
    QList<QLabel*> mTypeIconList;
    //天气污染指数
    QList<QLabel*> mAqiList;

    //风力和风向
    QList<QLabel*> mFxList;
    QList<QLabel*> mFlList;

    //天气图标
    QMap<QString,QString> mTypeMap;
};
#endif // MAINWINDOW_H
